<template>
  <div class="app-container">
    <el-button style="width: 80%; margin: 10px  auto;display: block;" type="success" @click="showModule">进入模拟</el-button>
    <el-divider>历史模拟</el-divider>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="试卷名称" prop="name">
          <el-input v-model="queryParams.name" placeholder="请输入试卷名称" clearable @keyup.enter.native="handleQuery"/>
        </el-form-item>
        <el-form-item label="试卷状态" prop="state">
          <el-select v-model="queryParams.state" placeholder="试卷状态" clearable
                     @keyup.enter.native="handleQuery">
            <el-option
              v-for="item in options.TRAIN_TEST_PAPER_STATE.list"
              v-bind="item"
              :key="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="试卷模板" prop="testPaperModuleId">
          <el-select v-model="queryParams.testPaperModuleId" placeholder="请输入试卷模板" clearable filterable
                     @keyup.enter.native="handleQuery">
            <el-option
              v-for="item in options.testPaperModuleList"
              :label="item.name"
              :value="item.id"
              :key="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="用户部门" prop="deptId">
          <dept-selector v-model="queryParams.deptId" placeholder="请输入考试时用户部门" clearable filterable @keyup.enter.native="handleQuery"/>
        </el-form-item>
        <el-form-item label="用户岗位" prop="postId">
          <post-selector v-model="queryParams.postId" placeholder="请输入考试时用户岗位" clearable filterable @keyup.enter.native="handleQuery"/>
        </el-form-item>
        <el-form-item label="岗位能力" prop="postLevelCode">
          <el-select v-model="queryParams.postLevelCode" placeholder="请输入考试时用户岗位能力" clearable
                     @keyup.enter.native="handleQuery">
            <el-option
              v-for="item in dict.type.post_level"
              v-bind="item"
              :key="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          <el-button icon="el-icon-close" size="mini" type="danger" @click="outTrain">退出</el-button>
        </el-form-item>
      </el-form>

      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                     >导出
          </el-button>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>

      <el-table border v-loading="loading" :data="ExamTestPaperList">
        <el-table-column resizable show-overflow-tooltip label="试卷名称" align="center" prop="name"/>
        <el-table-column resizable show-overflow-tooltip label="试卷模板" align="center" prop="testPaperModuleName"/>
        <el-table-column resizable show-overflow-tooltip label="人员" align="center" prop="userName"/>
        <el-table-column resizable show-overflow-tooltip label="总数量" align="center" prop="questionNum"/>
        <el-table-column resizable show-overflow-tooltip label="正答数量" align="center" prop="rightAnswerNum"/>
        <el-table-column resizable show-overflow-tooltip label="未做数量" align="center" prop="notDoneNum"/>
        <el-table-column resizable show-overflow-tooltip label="模糊数量" align="center" prop="vagueNum"/>
        <el-table-column resizable show-overflow-tooltip label="试卷状态" align="center" prop="stateStr"/>
        <el-table-column resizable show-overflow-tooltip label="提交时间" align="center" prop="submitTime" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.submitTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column resizable show-overflow-tooltip label="用户部门" align="center" prop="deptName"/>
        <el-table-column resizable show-overflow-tooltip label="用户岗位" align="center" prop="postName"/>
        <el-table-column resizable show-overflow-tooltip label="岗位能力" align="center" prop="postLevelCode">
          <template>

          </template>
        </el-table-column>
        <el-table-column resizable show-overflow-tooltip label="试卷总分数" align="center" prop="grade"/>
        <el-table-column resizable show-overflow-tooltip label="用户得分" align="center" prop="gainGrade"/>
        <el-table-column resizable label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)"
                       v-if="scope.row.state === options.TRAIN_TEST_PAPER_STATE.enums.FINISH.value">查看
            </el-button>
            <el-button size="mini" type="text" icon="el-icon-edit" @click="startTest(scope.row)"
                       v-if="scope.row.state === options.TRAIN_TEST_PAPER_STATE.enums.WAIT_SUBMIT.value">开始模拟
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                  @pagination="getList"/>
    </div>
    <el-dialog :visible.sync="visible" width="1400px">
      <test-paper-module ref="testPaperModule" @close="() => {this.visible = false}"/>
    </el-dialog>
  </div>
</template>
<script src="./simulationTrain.js"></script>
